#ifndef	_PanMoveOutDet_h_
#define _PanMoveOutDet_h_

#include "define.h"

#define PHASE_CHECK_FRE		30000	
#define	MIN_PHASE_ANGLE		10		
#define	PHASE_CHANGE		7		
#define	Pot_Pulse_Max		15		

#define		CheckPanPhaseMax_1		85
#define		CheckPanPhaseMax_2		70//76/*65*/
#define		CheckPanPhaseMin		15//30
#define		CheckPanPhaseStable		7
#define		CheckPanPhaseChange		20
#define		Phase_Angle_Conversion_Clock_num	(360*8)	//(360*2)		//0.25us>>1/4MHZ  

#define		MoveInCntMaxTH		60		
#define		MoveOutCntCheckTH	3
#define		PhaseAngle_Iron		85	
#define		PhaseAngle_304		75	

typedef enum
{
	TMC_CLK_Fsys_DIV4		= (unsigned char) 0x00,	/**<  Fsys/4 */
	TMC_CLK_Fsys			= (unsigned char) 0x10,	/**<  Fsys */
	TMC_CLK_FH_DIV16		= (unsigned char) 0x20,	/**<  FH/16 */
	TMC_CLK_FH_DIV64		= (unsigned char) 0x30,	/**<  FH/64 */
	TMC_CLK_Fsub			= (unsigned char) 0x40,	/**<  Fsub */
	TMC_CLK_TMCCKO_Raising	= (unsigned char) 0x60,	/**<  TMCCKO rising edge */
	TMC_CLK_TMCCKO_Falling	= (unsigned char) 0x70,	/**<  TMCCKO falling edge */
}TMC_Clock_TypeDef;
//TMC clock select



unsigned int  Phase_Capture();
unsigned char Time2Angle(unsigned int Temp_Phase_Num);
void PHASE_Capture_Init2(unsigned char TMC_Clock);
void Check_Pan_Moveout_Current();
void Check_Pan_Movein_Phase();
void PotMoveOut();
void PotExist();
void  Check_Pan_Moveout_Phase();
unsigned char PotCheck();

//void PHASE_Capture_Init(unsigned char TMC_Clock);
//unsigned char PanMoveOutDet(u16 TempIacStable,u16 TempIac1,u16 TempIacMinTH,u16 Percentage,u16 TempI_ChangeTH);
//unsigned char PhasePanMoveOutDet(u8 TempPhaseStable,u8 TempPhase0,u8 TempPhaseMinTH,u8 TempPhaseMaxTH,u8 TempPhaseChange);
//unsigned char PotCheck_machine_on();
//unsigned int  Phase_Capture1();
//unsigned char Time2Angle1(unsigned int Temp_Phase_Num);

extern vu8	PanMoveOutCnt;
extern vu16	PhaseNum;
extern vu8	PhaseAngle[3];

#endif

/******************* End of file ***************/